<style>
    .grid-view{
        padding-bottom: 20;
    }
</style>

<?php
//    $cs=Yii::app()->getClientScript();
//    $cs->registerCoreScript('yiigridview');

		$cs=Yii::app()->getClientScript();
		$cs->registerCoreScript('multifile');
?>

<SCRIPT type="text/javascript">
            
    var $tabs;
    var tabCounter = 50;
    $(document).ready(function () {
            $( "#tabs" ).bind( "tabsselect", function(event, ui) {
//                alert(tabitems[ui.index]);
                if(tabitems[ui.index] == 'accountingvoucher'){
                    shortcut.add("Ctrl+A",function() {
                                saveAccountingVoucher("clear");
                    });
                    shortcut.add("Ctrl+S",function() {
                                accountingvouchersFormSubmit();
                    });
                }
                else{
                    //Remove the shortcut
                    shortcut.remove("Ctrl+A");
                    shortcut.remove("Ctrl+S");
                }
//                alert(tabitems[$tabs.tabs('option', 'selected')]);
            });            

        //        $("#tabs").height('99%');
        // TABS-CENTER - sortable
        $tabs = $("#tabs").tabs(
        {
            tabTemplate: "<li><a href='#{href}'>#{label}</a> <span class='ui-icon ui-icon-close'>Remove Tab</span></li>",
            cache: true,
            add: function( event, ui ) {
                $("#tabs").tabs("select", "#" + ui.panel.id); 
                var tab_content = $tab_content_input.val() || "Tab " + tab_counter + " content.";
                $( ui.panel ).append( "<p>" + tab_content + "</p>" );
            },
            ajaxOptions: {
                error: function( xhr, status, index, anchor ) {
                    $( anchor.hash ).html(
                    "Couldn't load this tab. We'll try to fix this as soon as possible. " +
                        "If this wouldn't be a demo." );
                }
            }
                    
        }
    );
            
        // close icon: removing the tab on click
        // note: closable tabs gonna be an option in the future - see http://dev.jqueryui.com/ticket/3924
        $( ".ui-layout-center span.ui-icon-close" ).live( "click", function() {
            var index = $( "li", $tabs ).index( $( this ).parent() );
            $tabs.tabs( "remove", index );
            tabitems.splice( index, 1 );
        });
           
            
    });
    var tabitems = ['about'];

    // onClick event of the Add New Tab button
    function add_tab (id, url, title) {
        index = $.inArray(id, tabitems);
        if(index == -1){
            tabitems.push(id);            
            $("#tabs").tabs( "add", url, title);            
//            $( "#tabs" ).bind( "tabsload", function(event, ui) {
//                alert("remove..");
//            });            
            //            
        }
        else{
            $("#tabs").tabs( "select", index);
        }
        //                alert(tabCounter);
        //        $tabs.tabs( "add", "index.php?r=ccward/admin&isAjaxRequest=1", "Tab "+ (++tabCounter));
    };
    function show_tab () {
        alert($tabs.tabs('option', 'selected'));
        
        //                alert(tabCounter);
    };
            
</SCRIPT>


<?php
Yii::app()->session['rowcount'] = 1;
Yii::app()->session['rawdata'] = NULL;
$this->widget('zii.widgets.jui.CJuiTabs', array(
    'id' => 'tabs',
    'tabs' => array(
        //Yii::t('application', 'About') => array('ajax' => CController::createUrl('about', array('isAjaxRequest' => '1'))),
        //Yii::t('application', 'About') => array('ajax' => CController::createUrl('acledger/admin', array('isAjaxRequest' => '1'))),
//        Yii::t('application', 'Caseregs') => array('ajax' => CController::createUrl('casereg/admin', array('isAjaxRequest' => '1'))),
        Yii::t('application', 'Accounting Vouchers') => array('ajax' => CController::createUrl('transactionmaster/admin', array('isAjaxRequest' => '1'))),
        //Yii::t('application', 'Accounting Voucher') => array('ajax' => CController::createUrl('transaction/contra', array('isAjaxRequest' => '1', 'init'=>'1'))),
    ),
));
?>

<?php
$this->beginWidget('zii.widgets.jui.CJuiDialog', array(
    'id' => 'dialog',
    'options' => array(
        'closeOnEscape' => true,
        'autoOpen' => false,
        'modal' => true,
        'width' => 'auto',
        'height' => 'auto',
        'minHeight' => 50,
        'close' => 'js:function(){}'
    ),
))
?>
<?php $this->endWidget() ?>

<?php
$this->beginWidget('zii.widgets.jui.CJuiDialog', array(// the dialog
    'id' => 'dialog-popup-select',
    'options' => array(
//        'title' => Yii::t('application', 'Cczones'),
        'autoOpen' => false,
        'modal' => true,
//        'width' => 550,
//        'height' => 470,
        'width' => 'auto',
        'height' => 'auto',
        'minHeight' => 50,
        'close' => 'js:function(){ 
                if(window.selectedvalue){
                    $("#"+window.cid+"-form").find("#" + window.autocomplete).val(window.selectedvalue);
                    window.selectedvalue = null;
                }
            }',
    ),
));
?>
<?php $this->endWidget(); ?>

<?php
$this->beginWidget('zii.widgets.jui.CJuiDialog', array(// the dialog
    'id' => 'dialog-delete',
    'options' => array(
        'title' => Yii::t('application', 'Delete'),
        'autoOpen' => false,
        'modal' => true,
        'buttons' => array(
            'Delete' => 'js:function(){
                        jQuery.ajax(
                        {
                            "type":"POST",
                            "url": window.url+"&isAjaxRequest=1&id="+$.fn.yiiGridView.getSelection(window.cid+"-grid"),
                            "success":function(data){
                                $.fn.yiiGridView.update(window.cid+"-grid", {
                                        data: $(this).serialize()
                                });
                            },
                            "cache":false
                        }
                        );         
                        $(this).dialog("close");
                    }',
            'Cancel' => 'js:function(){ window.cid=null; window.url=null; $(this).dialog("close");}',
        ),
    ),
));
?>
<div id="dialog-delete" title="Empty the recycle bin?">
    <p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>These items will be permanently deleted and cannot be recovered. Are you sure?</p>
</div>
<?php $this->endWidget(); ?>

<?php
$this->beginWidget('zii.widgets.jui.CJuiDialog', array(// the dialog
    'id' => 'dialog-warning',
    'options' => array(
        'title' => Yii::t('application', 'Warning'),
        'autoOpen' => false,
        'modal' => true,
        'width' => 250,
        'height' => 120,
    ),
));
?>
<div id="dialog-warning">
    <p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span><div id="dialog-warning-msg"></div></p>
</div>
<?php $this->endWidget(); ?>

<?php
$this->beginWidget('zii.widgets.jui.CJuiDialog', array(// the dialog
    'id' => 'dialog-popup-casepersons',
    'options' => array(
//        'title' => Yii::t('application', 'Cczones'),
        'autoOpen' => false,
        'modal' => true,
//        'width' => 550,
//        'height' => 470,
        'width' => 'auto',
        'height' => 'auto',
        'minHeight' => 50,
        'close' => 'js:function(){ 
                if(window.idselected){
                    js:$("#"+window.cid+"-form").find("#"+window.eid).val(window.idselected); 
                    jQuery.ajax(
                    {
                        "type":"POST",
                        "dataType":"json",
                        "data":{"cid":window.idselected},"url":window.url,
                        "success":function(data){$("#"+window.eid+"_msg").text(data.message);},
                        "cache":false
                    }
                    );
                    window.idselected = null;
                }
            }',
    ),
));
?>
<?php $this->endWidget(); ?>


<?php
$this->beginWidget('zii.widgets.jui.CJuiDialog', array(// the dialog
    'id' => 'dialog-furldelete',
    'options' => array(
        'title' => Yii::t('application', 'Delete'),
        'autoOpen' => false,
        'modal' => true,
        'buttons' => array(
            'Delete' => 'js:function(){
                        jQuery.ajax(
                        {
                            "type":"POST",
                            "dataType":"json",
                            "url": window.furl,
                            "success":function(data){
                                if($("#" + window.cid).hasClass("last")){
                                    $("#" + window.cid).prev().addClass("last");
                                }
                                $("#" + window.cid).remove();
                            },
                            "cache":false
                        }
                        );         
                        $(this).dialog("close");
                    }',
            'Cancel' => 'js:function(){ window.furl=null; $(this).dialog("close");}',
        ),
    ),
));
?>
<div id="dialog-furldelete" title="Trash File?">
    <p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>These items will be permanently deleted and cannot be recovered. Are you sure?</p>
</div>
<?php $this->endWidget(); ?>
